<html>
<head><meta charset="utf-8"><title>size-of-fn-pointer-versus-data-pointer · t-lang/wg-unsafe-code-guidelines · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/index.html">t-lang/wg-unsafe-code-guidelines</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/size-of-fn-pointer-versus-data-pointer.html">size-of-fn-pointer-versus-data-pointer</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="132707297"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/size-of-fn-pointer-versus-data-pointer/near/132707297" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/size-of-fn-pointer-versus-data-pointer.html#132707297">(Aug 24 2018 at 17:19)</a>:</h4>
<p>So I'm sure that <code>sizeof(void*)</code> (data pointer) and <code>sizeof(void (*)())</code> (fn pointer) in C are not guaranteed to be the same — does anyone know of any actual architectures where data and function pointers are really different?</p>



<a name="132709954"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/size-of-fn-pointer-versus-data-pointer/near/132709954" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/size-of-fn-pointer-versus-data-pointer.html#132709954">(Aug 24 2018 at 18:03)</a>:</h4>
<p>16-bit PIC microcontrollers, apparently, and also classic DOS 8086 machines</p>



<a name="132710223"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/size-of-fn-pointer-versus-data-pointer/near/132710223" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/size-of-fn-pointer-versus-data-pointer.html#132710223">(Aug 24 2018 at 18:07)</a>:</h4>
<p>the POSIX standard apparently only requires that <code>void (*)()</code> be storable in <code>void*</code></p>



<a name="132710356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/size-of-fn-pointer-versus-data-pointer/near/132710356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/size-of-fn-pointer-versus-data-pointer.html#132710356">(Aug 24 2018 at 18:09)</a>:</h4>
<p>as in, fn ptrs must be smaller?</p>



<a name="132710365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/size-of-fn-pointer-versus-data-pointer/near/132710365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/size-of-fn-pointer-versus-data-pointer.html#132710365">(Aug 24 2018 at 18:09)</a>:</h4>
<p>is that the case on this architectures you mentioned?</p>



<a name="132710493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/size-of-fn-pointer-versus-data-pointer/near/132710493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/size-of-fn-pointer-versus-data-pointer.html#132710493">(Aug 24 2018 at 18:11)</a>:</h4>
<p>not on 16-bit pic - SRAM is more expensive than ROM, so data pointers can be smaller, apparently</p>



<a name="132710578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/size-of-fn-pointer-versus-data-pointer/near/132710578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/size-of-fn-pointer-versus-data-pointer.html#132710578">(Aug 24 2018 at 18:12)</a>:</h4>
<p>and the Medium memory model on x86 used 32-bit void(<em>)() and 16-bit void</em></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>